home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
scope
/
001-025
/
scopedisk6
/
enough
/
enough.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-18
|
1KB
|
48 lines
/**************
*
* Enough.c - Tests for the presence of a specified amount of free total ram and
* free chip ram.
*
* Synopsis - enough TOTAL [CHIP]
*
* Returns - 0 if enough total ram and chip ram is available.
* 10 (AmigaDOS ERROR level) if enough total ram or chip ram is not
* available.
*
* Author - Eric Kennedy ejkst@cisunx.edu
*
* Status - public domain
*
**************/
#include <exec/memory.h>
main(argc,argv)
char *argv[];
{
long freechip, freefast;
extern long AvailMem();
long reqchip = 0L;
long reqtot;
extern long atol();
if(argc>1) /* Is there a first argument? */
{
reqtot = atol(argv[1]);
if(argc > 2) /* Is there a second argument? */
reqchip = atol(argv[2]);
}
else
exit(20); /* no error message--keep it small */
Forbid(); /* get available memory */
freechip = AvailMem (MEMF_CHIP);
freefast = AvailMem (MEMF_FAST);
Permit();
/* compare to requested mem */
if((freechip >= reqchip) && (freechip+freefast >= reqtot))
exit(0); /* there was enough */
else
exit(10); /* there wasn't enough */
}